package me.stephenj.experiment2.mapper;

import me.stephenj.experiment2.model.Mails;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;

/**
 * @Title MailsMapper.java
 * @Description MailsMapper类
 * @author 张润天
 * @Time 2020/4/21 12:36
 * @version v0.01
 */

@Component
public interface MailsMapper {

    /**
     * @Title Method
     * @Description 查看最大的邮箱组编号
     */
    @Select("SELECT MAX(`ID`) FROM Mails")
    int max();

    /**
     * @Title Method
     * @Description 根据邮箱组编号查看邮箱组信息
     */
    @Select("SELECT * FROM Mails WHERE ID=#{ID}")
    Mails getAll(int ID);

    /**
     * @Title Method
     * @Description 添加新的邮箱组
     */
    @Insert("INSERT INTO Mails (ID, MailIDA, MailIDB) VALUE (#{ID}, #{MailIDA}, #{MailIDB})")
    int insert(Mails mails);

    /**
     * @Title Method
     * @Description 修改邮箱组信息
     */
    @Update("UPDATE Mails SET MailIDA=#{MailIDA}, MailIDB=#{MailIDB} WHERE ID=#{ID};")
    int update(Mails mails);

    /**
     * @Title Method
     * @Description 删除邮箱组
     */
    @Delete("DELETE FROM Mails WHERE ID=#{ID}")
    int delete(int ID);
}
